#include <algorithm>
#include <cassert>
#include <ctime>
#include <cstdlib>
#include <cstddef>
#include <fstream>
#include <iostream>
#include <iterator>
#include <vector>

using namespace std ;

bool lt_nocase(char c1, char c2)
{
	return tolower(c1) < tolower(c2) ;
}

bool gt_nocase(char c1, char c2)
{
	return tolower(c1) > tolower(c2) ;
}

int main ( )
{
	string str1 = "fdBeACFDbEac" ;
	cout<< "-----Original:" << str1 << endl ;
	
	string str2 = str1 ;
	stable_sort(str2.begin(), str2.end(), lt_nocase) ;
	cout<< "Stable Sorted:" << str2 << endl ;

	string str3 = str1 ;
	sort(str3.begin(), str3.end(), lt_nocase) ;
	cout<< "-------Sorted:" << str3 << endl ;

	cout<< "-----Original:" << str1 << endl ;
	
	string str4 = str1 ;
	stable_sort(str4.begin(), str4.end(), gt_nocase) ;
	cout<< "Stable Sorted:" << str4 << endl ;

	string str5 = str1 ;
	sort(str5.begin(), str5.end(), gt_nocase) ;
	cout<< "-------Sorted:" << str5 << endl ;
	
	int ints[10] = {9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
	vector<int> vec(ints, ints+10) ;  
	cout<< "-----Original:" ;
	copy(vec.begin(), vec.end(), ostream_iterator<int>(cout, " ")) ; 
	partial_sort(vec.begin(), vec.begin()+(vec.end()-vec.begin())/2, vec.end()) ;
	cout<< endl << "PartialSorted:" ;
	copy(vec.begin(), vec.end(), ostream_iterator<int>(cout, " ")) ; 
	cout<< endl << "middle=" << *(vec.begin()+(vec.end()-vec.begin())/2) << endl ;

	return 0 ;
}
